package com.dgut.demo.controller;

import com.dgut.demo.bean.DispatchMessage;
import com.dgut.demo.service.DispatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Auther 虎
 * @Data 2021/2/24 15:05
 * @Version 1.0
 */
@RestController
public class DispatchController {
    @Autowired
    private DispatchService dispatchService;

    @GetMapping("/getAllDispatchMessage")
    public List<DispatchMessage> getAllDispatchMessage(){
        return dispatchService.getAllDispatchMessage();
    }

    @GetMapping("/getDispatchMessageByDid")
    public List<DispatchMessage> getDispatchMessageByDid(String did){
        return dispatchService.getDispatchMessageByDid(did);
    }

    @GetMapping("/getDispatchMessageByVid")
    public List<DispatchMessage> getDispatchMessageByVid(String dvid){
        return dispatchService.getDispatchMessageByVid(dvid);
    }

    @GetMapping("/getDispatchMessageByPhone")
    public List<DispatchMessage> getDispatchMessageByPhone(String dvphone){
        return dispatchService.getDispatchMessageByPhone(dvphone);
    }

    @GetMapping("/getDispatchMessageByEname")
    public List<DispatchMessage> getDispatchMessageByEname(String dename){
        return dispatchService.getDispatchMessageByEname(dename);
    }

    @GetMapping("/getDispatchMessageByGname")
    public List<DispatchMessage> getDispatchMessageByGname(String dgname){
        return dispatchService.getDispatchMessageByGname(dgname);
    }

    @PostMapping("/addOneDispatchMessage")
    public int addOneDispatchMessage(String dvid,String deid,String dgid,int dcounts, String dtype){
        DispatchMessage dispatchMessage = new DispatchMessage();
        dispatchMessage.setDcounts(dcounts);
        dispatchMessage.setDeid(deid);
        dispatchMessage.setDgid(dgid);
        dispatchMessage.setDvid(dvid);
        dispatchMessage.setDtype(dtype);
        return dispatchService.addOneDispatchMessage(dispatchMessage);
    }
}
